<?php
namespace Home\Controller;
use Think\Controller,  
    Model\News_classModel,
    Model\News_contentsModel,
    Model\LinkModel,
    Model\Link_classModel,
    Model\SystemModel;

class IndexController extends Controller {
    public function index(){
        $ncmd  = new News_classModel();
        $nctmd = new News_contentsModel();
        $lcmd  = new Link_classModel();
        $lkmd  = new LinkModel();
        $stmd  = new SystemModel();

        
        //父级栏目
        $flist = $ncmd  -> where('state=1') -> order('sort asc') -> select();
        //内容
        $zlist = $nctmd -> where('state=1') -> order('sort asc') -> select();
        
        //二级栏目排序第一内容展示
        $classA = $ncmd -> order('sort asc') -> find();
        $listA  = $nctmd -> where("n_id = {$classA['id']} AND state=1") -> order('sort desc') -> limit(6) -> select();
     
        //二级栏目排序第二内容展示
        $classB = $ncmd  -> order('sort asc')  -> limit(1,1)-> select();
        $listB  = $nctmd -> where("n_id = {$classB[0]['id']} AND state=1") -> order('sort desc') -> limit(4) -> select();

        //二级栏目排序第三内容展示
        $classC = $ncmd  -> order('sort asc') -> limit('2,1') -> select();
        $listC  = $nctmd -> where("n_id = {$classC[0]['id']} AND state=1") -> order('sort desc') -> limit(4) -> select();
        
        //二级栏目排序第三内容展示
        $classD = $ncmd  -> order('sort asc') -> limit('3,1')  -> select();
        $listD  = $nctmd -> where("n_id = {$classD[0]['id']} AND state=1")    -> order('sort desc') -> limit(2)   -> select();
        $listD2 = $nctmd -> where("n_id = {$classD[0]['id']} AND state=1")    -> order('sort desc') -> limit(2,4) -> select();
        $listD3 = $nctmd -> where("n_id = {$classD[0]['id']} AND state=1")    -> order('sort desc') -> limit(6,4) -> select();
        
        //底部链接
        $flink = $lcmd -> where('link_class_state=0') -> order('link_class_sort asc') -> select(); 
        $zlink = $lkmd -> order('link_sort asc')      -> select(); 
        
        //导航条链接
        $dlink = $lcmd -> where('link_class_state=1') -> order('link_class_sort asc') -> select(); 

        //顶部LOGO
        $index_logo = $stmd -> where("system_name='index_logo'") -> find();
       
        //网站名称
        $web_name = $stmd -> where("system_name='web_name'") -> find();
        
        //轮播图
        $round = $nctmd -> where('index_round=1 AND state=1')-> order('sort desc')  -> find();
        $roundB = $nctmd -> where('index_round=1 AND state=1')-> order('sort desc')  -> limit(1,5) -> select();
         
        
        $this -> assign('round',$round);      
        $this -> assign('roundB',$roundB);      
        $this -> assign('web_name',$web_name);      
        $this -> assign('flink',$flink);      
        $this -> assign('zlink',$zlink);      
        $this -> assign('dlink',$dlink);      
        $this -> assign('flist',$flist);
        $this -> assign('zlist',$zlist);
        $this -> assign('classA',$classA);
        $this -> assign('listA',$listA);
        $this -> assign('classB',$classB[0]);
        $this -> assign('listB',$listB);
        $this -> assign('classC',$classC[0]);
        $this -> assign('listC',$listC);
        $this -> assign('classD',$classD[0]);
        $this -> assign('listD',$listD);
        $this -> assign('listD2',$listD2);
        $this -> assign('listD3',$listD3);
        $this -> assign('index_logo',$index_logo);
        $this -> display();
     
    }
}